package com.dagger.enums;

import java.util.HashMap;

import lombok.Getter;

/**
 * 消息类型枚举
 * @author dagger
 *
 */
@Getter
public enum MsgTypeEnum {
	DELAY("DELAY", "延时消息"),

	REALTIME("REALTIME", "实时消息"),

	INTERACTIVE("INTERACTIVE", "交互消息"),;

	private String code;
	private String name;

	MsgTypeEnum(String code, String name) {
		this.code = code;
		this.name = name;
	}

	private final static HashMap<String, MsgTypeEnum> VALUE_MAP = new HashMap<>();

	static {
		for (MsgTypeEnum o : MsgTypeEnum.values()) {
			VALUE_MAP.put(o.getCode(), o);
		}
	}

	public static String getName(String code) {
		if (code == null) {
			return null;
		}
		MsgTypeEnum v = VALUE_MAP.get(code);
		if (v == null) {
			return null;
		}
		return v.getName();
	}

	public static Boolean containsCode(String code) {
		return VALUE_MAP.containsKey(code);
	}
}
